<?php 
include "includes/session.php";
include "includes/comunes.php";
require_once("includes/paginator.class.php");

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>Sistema de Registro de Atencion</title>

<link href="estilos.css" rel="stylesheet" type="text/css" />

<!--libreria jquery central-->

<script src="jquery-ui/js/jquery-1.9.1.js"></script>
<!--fin libreria central-->

<!--Librerias para el combo-->
<script language="JavaScript" type="text/javascript" src="combos/jquery.chainedSelects.js"></script>
<!--fin libreria-->

<!--librerias ui-->
<link href="jquery-ui/css/ui-lightness/jquery-ui-1.10.2.custom.css" rel="stylesheet"/>
<script src="jquery-ui/js/jquery-ui-1.10.2.custom.js"></script>
<!--fin libreria-->
<!--libreria flexigrid-->
<link rel="stylesheet" type="text/css" href="jquery-ui/css/ui-flexigrid/flexigrid.css">
    <script type="text/javascript" src="jquery-ui/js/flexigrid.js"></script>
<!--fin libreria-->
<!--VENTANA MODAL -->
<link href="modal/styles/modal-window.css" type="text/css" rel="stylesheet" /> 
 
		<script type="text/javascript" language="javascript" src="modal/scripts/modal-window.min.js"></script>  


<script language="JavaScript" type="text/javascript">
$(function()
{

<?php  for ($a=1;$a<=30;$a++):?>
		
		$( "#codigo<?php echo $a?>" ).autocomplete({
			source: "autoArticulosCompleto.php",
			minLength: 2,
                select: function(event, ui) {
					$("#codigo<?php echo $a?>").val(ui.item.value);
					$("#precio<?php echo $a?>").val(ui.item.costo);
					$("#cant<?php echo $a?>").val(ui.item.tipo);
            
                }
		});
              
<?php endfor?>

//multiplico los valores 
<?php  for ($a=1;$a<=30;$a++):?>
$(document).on("change","#precio<?php echo $a?>",function(){
                        precio = $("#precio<?php echo $a?>").val() ;
						cantidad = $("#cant<?php echo $a?>").val() ;
						total = precio * cantidad;
						iva= total*0.21;
						total=total+iva;
						$("#total<?php echo $a?>").val(total);
						$("#iva<?php echo $a?>").val(iva);
             });
<?php endfor?>

<?php  for ($a=1;$a<=30;$a++):?>
$(document).on("change","#cant<?php echo $a?>",function(){
                        precio = $("#precio<?php echo $a?>").val() ;
						cantidad = $("#cant<?php echo $a?>").val() ;
						total = precio * cantidad;
						iva= total*0.21;
						total=total+iva;
						$("#total<?php echo $a?>").val(total);
						$("#iva<?php echo $a?>").val(iva);
             });
<?php endfor?>



	  $( "#menu" ).menu({position: {at: "left bottom"}});

});
</script>



</head>

<body>

<div class="container">
<?php include "includes/head.php"?>
   <div class="content">
       <div class="tituloprincipal"><img src="img/purchase.png" width="25" height="25" border="0"/> Alta Orden de Compra
           <?php include 'includes/submenu.php';?>  
           </div>
       
       <div class="contenedorpedido">
       <form id="altapedido" name="altapedido" method="POST" action="grabarOrdenCompra.php">
        <fieldset>
             <legend><b>Datos de Cabecera</b></legend>
             <table width="100%">
                 <tr>

                    <td class="textotablamenuform">Fecha</td>
                    <td class="textotablamenuform"><input type="text" name="fecha" id="fecha" disabled value="<?php echo format_fec(date("Y-m-d"),"/")?>" class="campo_form" /></td>
                    <td class="textotablamenuform"> Nro Orden Proveedor</td>
                    <td class="textotablamenuform" colspan="3">
					<input type="text" name="numero" id="numero" value="0" required class="campo_form" />
					 
						  </td>
                    
<td class="textotablamenuform"></td>				
                 </tr>
                 <tr>
                      <td class="textotablamenuform">Proveedor</td>
                     <td class="textotablamenuform" colspan="5">
                          <select class="campo_form" name="proveedor" id="proveedor" required>
						   
						   <?php 
						   $resRub=obtener_prov_vehiculos();
						   while($regRub=mysql_fetch_array($resRub)):?>
						   <option value="<?php echo $regRub['ProveedorId']?>"><?php echo $regRub['ProveedorNombre']?></option>
						   <?php endwhile ?>
						  </select>
                     </td>
                     
                    
                 </tr>
				 <tr>
                      <td class="textotablamenuform">Sucursal</td>
                     <td class="textotablamenuform" colspan="5">
                          <select class="campo_form" name="sucursal" id="sucursal" required>
						   
						   <?php 
						   $resRub=obtener_sucursales();
						   while($regRub=mysql_fetch_array($resRub)):?>
						   <option value="<?php echo $regRub['sucursalId']?>"><?php echo utf8_encode($regRub['sucursalNombre'])?></option>
						   <?php endwhile ?>
						  </select>
                     </td>
                     
                    
                 </tr>
                 <tr>
                    <td class="textotablamenuform">Observacion </td>
                    <td class="textotablamenuform" colspan="3"><input type="text" name="observacion" id="observacion" value="" class="campo_form" /></td>
                    
                        </tr>
                 
                   
             </table>
        </fieldset>
      
           <fieldset>
             <legend><b>Detalle de Orden de Compra</b></legend>
             
             </br>

             <table >
			 <tr>
			 <td class="textotablamenuform" style="width:50%;">Articulo</td>
			 <td class="textotablamenuform">Cant..</td>
			<td class="textotablamenuform">Costo</td>
			<td class="textotablamenuform">Iva</td>
             <td class="textotablamenuform">Total</td>
			 </tr>
  
               <tbody>

                <?php
                
                for($i=1;$i<=30;$i++):?>
                  <tr id="fila<?php echo $i?>">
                     
                     <td ><input  type="text" style="width:90%;" name="codigo<?php echo $i?>" id="codigo<?php echo $i?>"  value="" class="campo_form"/></td>
					<td ><input  type="number"  name="cant<?php echo $i?>" id="cant<?php echo $i?>"  style="width:90%;" value="0" class="campo_form"/></td> 
					<td ><input  type="number" step="0.01" name="precio<?php echo $i?>" id="precio<?php echo $i?>"  value="0" style="width:90%;" class="campo_form"/></td>	
					<td ><input  type="number" step="0.01" name="iva<?php echo $i?>" id="iva<?php echo $i?>"  value="0" style="width:90%;" class="campo_form"/></td>						
					<td ><input  type="number"   step="0.01"  name="total<?php echo $i?>" id="total<?php echo $i?>"  value="0"  style="width:90%;"value="" class="campo_form"/></td>
					
                     
                  </tr>
                 <?php
                 endfor
                
                 ?>

                  
                </tbody>

             </table>
             

        </fieldset>
           <fieldset>
             
             <table>
              
                   <tr>
                  <td class="textotablamenuform" style="width:90%;">

						
						 </td>
                         <td class="textotablamenuform" style="text-align: right;" align="right">

						 <input type="submit" name="grabar" value="Grabar Orden de Compra"  class="boton_form"/>
						 </td>
                    	</tr>
						
						<!--<tr>
						 <td class="textotablamenuform" style="text-align: right;" > </td>
					
						 <td class="textotablamenuform" style="text-align: right;" > <input name="10x5" id="submit" type="submit" value="Etiquetas 10x5" class="boton_form"/> </td>
						<td class="textotablamenuform" style="text-align: right;" >  <input name="10x8" id="submit" type="submit" value="Etiquetas 10x8" class="boton_form"/> </td>
                    
                 </tr>-->
             </table>
        </fieldset>
		 </form>
       </div>
 
       <div class="clear"></div>
   <br>
   </div>
  <?php include "includes/pie.php"?>
  
</div>


</body>
</html>
